$(function() {
	readyclass("classID-select");
	readysubject("subject-select")
	readyresult(null);   //初始化，显示第1页，-1表示页面初始化
	$("#seek-button").click(function() {
		readyresult($("#subject-select").val());
	})
})
function readyresult(subcode) {
	var classid = $("#classID-select").val();
	if (classid == "-1")
		classid = "";
	
	$.ajax({
		url : "/blackhouse/classcj",
		type : "post",
		data : {
			"classid" : classid,
			"subcode":subcode
		},
		dataType : "json",
		success : function(e) {
			var html = "";
			for (var i = 0; i < e.length; i++) {
				html += "<tr>";
				html += "<td>" + e[i].gradename + "</td>";
				html += "<td>" + e[i].classname + "</td>";
				html += "<td>" + e[i].stuCode + "</td>";
				html += "<td>" + e[i].stuName + "</td>";
				html += "<td>" + e[i].subjectName + "</td>";
				html += "<td>" + e[i].result + "分</td>";
				html += "</tr>"
			}
			$("#result-tbody").html(html);
		}
	})
}
function readysubject(ID){
	 $.ajax({
	 		url : "/blackhouse/subject",
	 		type : "post",
	 		data:{"code":1},
	 		dataType : "json",
	 		success : function(e) {
	 			var html = "";
	 			for(var i = 0;i<e.length;i++){
	 				html += "<option value='" + e[i].id + "'>" + e[i].subjectname
					+ "</option>"
	 			}
	 			$("#"+ID).append(html);
	 		}
	 })
}
function readyclass(ID){
	$.ajax({
        url: "/blackhouse/seeclass",
        type: "post",
        dataType: "json",
        success: function(e) {
            var html = "<option value='-1'>全部</option>";
            for (var i = 0; i < e.length; i++) {
            	html += "<option value='" + e[i].id + "'>" + e[i].className
				+ "</option>"
            }
            $("#"+ID+"").html(html);
        }
    })
}

